/*
 * @Date: 2022-07-27 15:46:49
 * @LastEditors: Zzt
 * @LastEditTime: 2022-08-05 18:35:51
 * @FilePath: \archives-fe\src\view\sysMaintenance\TaskCronE\components\PageOperate.tsx
 */
import cs from 'classnames';
import { Button, Input, Space } from 'antd';
import AddPlan from './dialogs/AddPlan';
import styles from '../styles/TaskCronE.module.scss';
import classNames from 'classnames/bind';
import { useTaskCronEContext } from '../contexts/TaskCronEContext';
import { useEffect, useMemo, useState } from 'react';

const cx = classNames.bind(styles);
const { Search } = Input;

const PageOperate = () => {
  const { setSearch } = useTaskCronEContext();
  const onSearch = (value: string) => setSearch(value);
  useEffect(() => {
    setSearch(1);
  }, []);
  const [tFormVisible, setTFormVisible] = useState(false);

  const { deleteExportFunc, selectId } = useTaskCronEContext();
  return (
    <div className={cs('filter-container', 'page-operate')}>
      <div className={cx('seach')}>
        <Space size={'large'}>
          <p className="page-title">项目档案-项目排序</p>
          <Search
            placeholder="输入关键词快速查询"
            allowClear
            enterButton="查询"
            size="middle"
            onSearch={onSearch}
          />
        </Space>
      </div>
      <Space size="small">
        {useMemo(
          () => (
            <AddPlan
              visible={tFormVisible}
              onClose={() => {
                setTFormVisible(false);
              }}
            />
          ),
          [tFormVisible]
        )}
        <Button
          onClick={() => {
            deleteExportFunc(selectId, '是否删除选中的任务');
          }}
        >
          删除任务
        </Button>
      </Space>
    </div>
  );
};
export default PageOperate;
